# Lucid is (C) Copyright 2006-2007 by Infiscape Corporation
#
# This file is part of Lucid, a PyOpenSG example application.
#
# Lucid is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Lucid is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program.  If not, see <http://www.gnu.org/licenses/>.

import osg2

max_depth = 3
width = 2

osg2.osgInit([])

scene_root = osg2.Node.create()
scene_root.setCore(osg2.Group.create())
osg2.setName(scene_root, "R")

def genTree(root, depth):
   if depth >= max_depth:
      return
      
   for x in range(width):
      new_node = osg2.Node.create()
      root.addChild(new_node)
      
      new_node.setCore(osg2.Group.create())
      osg2.setName(new_node, "%s.%s"%(osg2.getName(root),x))
      genTree(new_node, depth+1)

genTree(scene_root, 0)

pt = osg2.helpers.PrintTreeTraverser()
pt.traverse(scene_root)

osg2.SceneFileHandler.the().write(scene_root, "test_scene_gen.osb")
